package com.anti.modular.sys.pos.controller;
import com.anti.commom.api.Result;
import com.anti.commom.enums.LogAnnotionOpTypeEnum;
import com.anti.jdbc.support.page.PageParam;
import com.anti.commom.annotation.BusinessLog;
import com.anti.modular.sys.pos.param.SysPosParam;
import com.anti.modular.sys.pos.service.SysPosService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 系统职位控制器
 */
@RestController
@RequestMapping("sysPos")
public class SysPosController {

    @Resource
    private SysPosService sysPosService;

    /**
     * 查询系统职位
     */
    @GetMapping("page")
    @BusinessLog(title = "系统职位_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public Result page(PageParam pageParam,SysPosParam sysPosParam) {
        return Result.data(sysPosService.page(pageParam,sysPosParam));
    }

    /**
     * 系统职位列表
     */
    @GetMapping("list")
    @BusinessLog(title = "系统职位_列表", opType = LogAnnotionOpTypeEnum.QUERY)
    public Result list(SysPosParam sysPosParam) {
        return Result.data(sysPosService.list(sysPosParam));
    }

    /**
     * 添加系统职位
     */
    @PostMapping("add")
    @BusinessLog(title = "系统职位_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public Result add(@RequestBody @Validated(SysPosParam.add.class) SysPosParam sysPosParam) {
        sysPosService.add(sysPosParam);
        return Result.success("添加成功！");
    }

    /**
     * 删除系统职位
     */
    @PostMapping("delete")
    @BusinessLog(title = "系统职位_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public Result delete(@RequestBody @Validated(SysPosParam.delete.class) SysPosParam sysPosParam) {
        sysPosService.delete(sysPosParam);
        return Result.success("删除成功！");
    }

    /**
     * 编辑系统职位
     */
    @PostMapping("edit")
    @BusinessLog(title = "系统职位_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public Result edit(@RequestBody @Validated(SysPosParam.edit.class) SysPosParam sysPosParam) {
        sysPosService.edit(sysPosParam);
        return Result.success("修改成功！");
    }

    /**
     * 查看系统职位
     */
    @GetMapping("detail")
    @BusinessLog(title = "系统职位_查看", opType = LogAnnotionOpTypeEnum.DETAIL)
    public Result detail(@Validated(SysPosParam.detail.class) SysPosParam sysPosParam) {
        return Result.data(sysPosService.detail(sysPosParam));
    }
}
